App.require(["matrix3"], function (matrix3) {
    var Matrix3 = matrix3.Matrix3;
    App.defineWidget("scatter", {
        render: function (ctx) {
            ctx.save();
            var style = this.style;
            if (style.option.length == 0) return;
            ctx.globalAlpha = style.opacity;
            var transforms = App.Widget.strToTransform(style.transform);
            if (transforms) {
                for (var i = 0; i < transforms.length; i++) {
                    var tranObj = transforms[i];
                    ctx[tranObj.key].apply(ctx, tranObj.param);
                }
            }
            var shadowObj = App.Widget.strToShadow(style.shadow);
            if (shadowObj) {
                ctx.shadowOffsetX = shadowObj.x;
                ctx.shadowOffsetY = shadowObj.y;
                ctx.shadowBlur = shadowObj.blur;
                ctx.shadowColor = shadowObj.color;
            }
            ctx.translate(style.x, style.y);

            var options = this.style.option;
            for (var i = 0; i < options.length; i++) {
                var obj = options[i], h = -parseFloat(obj.value), offsetX = obj.offset;
                ctx.save();
                ctx.translate(offsetX, h);
                ctx.beginPath();
                ctx.arc(0, 0, 10, 0, Math.PI * 2, false);
                if (style.fill) {
                    ctx.fillStyle = style.fill;
                    ctx.fill();
                }
                if (style.stroke) {
                    ctx.strokeStyle = style.stroke;
                    ctx.stroke();
                }
                ctx.restore();
            }
            ctx.restore();
        },
        style: {
            x: 0,
            y: 0,
            shadow: "0 0 0 black",
            percent: 1,
            mark: "",
            marker: "",
            markOffset: "",
            markerOffset: "",
            fill: "red",
            stroke: "black",
            linewidth: 1,
            linedash: "",
            linedashoffset: 0,
            direction: App.AxisDirectionOption.BOTTOMTOP,
            opacity: 1,
            percent: 1,
            option: [{offset: 30, value: 60 }, { offset: 80, value: 80 }]
        },
        get x() {
            return this.style.x;
        },
        set x(val) {
            this.style.x = val;
            this.getScene().nextRender();
        },
        get y() {
            return this.style.y;
        },
        set y(val) {
            this.style.y = val;
            this.getScene().nextRender();
        },
        get mark() {
            return this.style.mark;
        },
        set mark(val) {
            this.style.mark = val;
            this.getScene().nextRender();
        },
        get markOffset() {
            return this.style.markOffset;
        },
        set markOffset(val) {
            this.style.markOffset = val;
            this.getScene().nextRender();
        },
        get marker() {
            return this.style.marker;
        },
        set marker(val) {
            this.style.marker = val;
            this.getScene().nextRender();
        },
        get markerOffset() {
            return this.style.markerOffset;
        },
        set markerOffset(val) {
            this.style.markerOffset = val;
            this.getScene().nextRender();
        },
        get shadow() {
            return this.style.shadow;
        },
        set shadow(val) {
            this.style.shadow = val;
            this.getScene().nextRender();
        },
        get stroke() {
            return this.style.stroke;
        },
        set stroke(val) {
            this.style.stroke = val;
            this.getScene().nextRender();
        },
        get fill() {
            return this.style.fill;
        },
        set fill(val) {
            this.style.fill = val;
            this.getScene().nextRender();
        },
        get opacity() {
            return this.style.opacity;
        },
        set opacity(val) {
            this.style.opacity = val;
            this.getScene().nextRender();
        },
        get linewidth() {
            return this.style.linewidth;
        },
        set linewidth(val) {
            this.style.linewidth = val;
            this.getScene().nextRender();
        },
        get linedash() {
            return this.style.linedash;
        },
        set linedash(val) {
            this.style.linedash = val;
            this.getScene().nextRender();
        },
        get linedashoffset() {
            return this.style.linedashoffset;
        },
        set linedashoffset(val) {
            this.style.linedashoffset = val;
            this.getScene().nextRender();
        },
        get percent() {
            return this.style.percent;
        },
        set percent(val) {
            this.style.percent = val;
            this.getScene().nextRender();
        }
    })
})